﻿using System.Collections;
using System.Collections.Generic;
using Robotlegs.Bender.Bundles.MVCS;
using Robotlegs.Bender.Extensions.EventManagement.API;
using UnityEngine;

public class MyTextMediator : Mediator
{
	[Inject]
	public MyTextView myTextView;

	//当全部的属性变量注入对象成功的时候，将调用该函数
	public override void Initialize()
	{
		AddViewListener<ViewEvent>(ViewEvent.Type.REQUEST, Dispatch);
		AddViewListener<ViewEvent>(ViewEvent.Type.ADD, Dispatch);
		AddContextListener<CommandEvent>(CommandEvent.Type.REQUEST, UpdateScore);
		AddContextListener<CommandEvent>(CommandEvent.Type.ADD, UpdateScore);

	}

	private void UpdateScore(CommandEvent evt)
	{
		myTextView.UpdateScore(evt.score);
	}
}
